import time
from datetime import datetime
from fastapi import APIRouter

from api.models.response import HealthResponse
from shared.config import settings

router = APIRouter()

# 记录启动时间
start_time = time.time()


@router.get("/health", response_model=HealthResponse)
async def health_check():
    """健康检查接口"""
    return HealthResponse(
        status="healthy",
        version=settings.api_version,
        timestamp=datetime.now(),
        uptime=time.time() - start_time
    )


@router.get("/")
async def root():
    """根路径"""
    return {
        "service": settings.api_title,
        "version": settings.api_version,
        "status": "running"
    }